<template>
  <div class="newsSection">
    <div class="news-icon-title">
      <span class="iconfont icon-news">&#xe650;</span>
      <span class="news-title">今日健康焦点</span>
    </div>
    <div 
      v-for="(item, i) in newsList.slice(0, 5)" 
      :key="i"
      class="news">
      <el-row :gutter="20">
        <el-col :span="8">
          <div class="grid-content">
            <img
              :src="item.thumbnail"
              class="news-img"
              @click="showArticle(item.newsId)"
            />
          </div>
        </el-col>
        <el-col :span="16">
          <div class="grid-content" @click="showArticle(item.newsId)">
            <p class="news-content">{{ item.title }}</p>
            <p class="news-date">{{ item.publishTime }}</p>
          </div>
        </el-col>
    </el-row>
    </div>
  </div>
</template>

<script>
export default {
  name: "NewsSection",
  props: ["newsList"],
  methods: {
    async showArticle(newsId) {
      let link = this.$router.resolve({
        path: "/article",
        query: { 
          artId: newsId,
          isNews:true, 
          },
      });
      window.open(link.href, "_blank");
    },
  },
};
</script>

<style scopde lang="less">
.news-icon-title {
  padding-top: 10px;
  .icon-news {
    color: @themeColor;
    font-size: 30px;
    margin-right: 5px;
  }
  .news-title {
    font-size: 22px;
  }
}
.news {
  cursor: pointer;
  padding-top: 10px;
  border-bottom: 1px solid #d7d7d7;
  &:last-child {
    border-bottom: none;
  }
  .news-img {
    height: 90px;
    width: 90px;
    margin-left: 5px;
  }
  .news-content {
    margin-top: 10px;
    font-size: 16px;
    padding-right: 5px;
    overflow: hidden;
    text-overflow: ellipsis;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    &:hover {
      color: @themeColor;
    }
  }
  .news-date {
    position: absolute;
    bottom: 0;
    right: 0;
    color: #797979;
    font-size: 12px;
    text-align: right;
    margin-top: 20px;
    padding-right: 20px;
  }
}
</style>